package com.wondersgroup.framework.sample.component.form.action;

import com.wondersgroup.framework.core.web.struts2.action.BaseAjaxAction;
import com.wondersgroup.framework.core.web.vo.VOUtils;
import com.wondersgroup.framework.core5.model.vo.ValueObject;
import com.wondersgroup.framework.sample.component.form.vo.CodeInfoVO;
import com.wondersgroup.framework.sample.component.form.vo.LinkageVO;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

public class LinkageAction extends BaseAjaxAction
{
  private LinkageVO linkageVO;
  private static final String prefix = "{\"success\":true,result:[";
  private static final String suffex = "]}";
  List<CodeInfoVO> codeInfoResult;

  public LinkageAction()
  {
    this.linkageVO = new LinkageVO();

    this.codeInfoResult = new ArrayList();
  }

  public ValueObject getValueObject() {
    return this.linkageVO;
  }

  protected String operate()
  {
    return super.operate();
  }

  public String loadLinkageWith3Level()
  {
    LinkageVO vo = new LinkageVO();
    vo.setStreet("waitan");
    String json = "{\"success\":true,result:[" + VOUtils.getJsonData(vo) + "]}";
    createJSonData(json);
    return "ajax";
  }

  public String getCascadeDataWith3Level()
  {
    LinkageVO vo = new LinkageVO();
    vo.setDistrict("shanghai");
    vo.setCounty("huangpu");
    vo.setStreet("waitan");
    String json = VOUtils.getJsonData(vo);
    createJSonData(json);
    return "ajax";
  }

  public String getCascadeDataWith2Level() {
    LinkageVO vo = new LinkageVO();
    vo.setDistrict("shanghai");
    vo.setCounty("huangpu");
    vo.setCounty2("xuhui");
    String json = VOUtils.getJsonData(vo);
    createJSonData(json);
    return "ajax";
  }

  public String loadLinkageWith2Level()
  {
    LinkageVO vo = new LinkageVO();
    vo.setDistrict("shanghai");
    vo.setCounty("huangpu");
    vo.setCounty2("xuhui");
    String json = "{\"success\":true,result:[" + VOUtils.getJsonData(vo) + "]}";
    createJSonData(json);
    return "ajax";
  }

  public String submitFormWithLinkage3Level()
  {
    System.out.println("行政区划：" + this.linkageVO.getDistrict());
    System.out.println("所属区县：" + this.linkageVO.getCounty());
    System.out.println("所属街道：" + this.linkageVO.getStreet());
    return "ajax";
  }

  public String submitFormWithLinkage2Level()
  {
    System.out.println("行政区划：" + this.linkageVO.getDistrict());
    System.out.println("所属区县1：" + this.linkageVO.getCounty());
    System.out.println("所属区县2：" + this.linkageVO.getCounty2());
    return "ajax";
  }
}